<template>
    <div class="flow-container2">
  <div class="admin-layout">
    <!-- 只要不是 /admin/login 就显示侧边栏 -->
    <AdminSidebar v-if="!(route.path === '/admin/login')" />
    <div class="admin-content">
      <router-view />
    </div>
  </div>
  </div>
</template>

<script setup lang="ts">
import { onMounted } from 'vue'
import { useRoute } from 'vue-router'
import AdminSidebar from '../../components/AdminSidebar.vue'
import { useAdminAuth } from '../../composables/useAdminAuth'

const route = useRoute()
const { checkAndHandleExpiredToken, requireAdminRole } = useAdminAuth()

// 在布局组件挂载时检查管理员权限
onMounted(() => {
  // 如果不是登录页面，则检查权限
  if (route.path !== '/admin/login') {
    checkAndHandleExpiredToken()
    requireAdminRole()
  }
})
</script>

<style scoped>
.admin-layout {
  display: flex;
  height:100%;
  background: transparent;
}

.admin-content {
  flex: 1;
  margin-left: 200px;
}
</style>
